<template>
	<el-main class="bg edit_wrap comtable_e">
		<el-form ref="form" :model="form" status-icon label-width="120px" v-if="is_view()">
		<el-row class="row_ce"> 
							<el-col v-if="user_group === '管理员' || $check_field('get','player_name') || $check_field('add','player_name') || $check_field('set','player_name')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="球员姓名" prop="player_name">
												<el-input id="player_name" v-model="form['player_name']" placeholder="请输入球员姓名"
							  v-if="user_group === '管理员' || (form['assist_analysis_id'] && $check_field('set','player_name')) || (!form['assist_analysis_id'] && $check_field('add','player_name'))" :disabled="disabledObj['player_name_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','player_name')">{{form['player_name']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','player_position') || $check_field('add','player_position') || $check_field('set','player_position')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="球员位置" prop="player_position">
												<el-input id="player_position" v-model="form['player_position']" placeholder="请输入球员位置"
							  v-if="user_group === '管理员' || (form['assist_analysis_id'] && $check_field('set','player_position')) || (!form['assist_analysis_id'] && $check_field('add','player_position'))" :disabled="disabledObj['player_position_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','player_position')">{{form['player_position']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','player_age') || $check_field('add','player_age') || $check_field('set','player_age')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="球员年龄" prop="player_age">
												<el-input id="player_age" v-model="form['player_age']" placeholder="请输入球员年龄"
							  v-if="user_group === '管理员' || (form['assist_analysis_id'] && $check_field('set','player_age')) || (!form['assist_analysis_id'] && $check_field('add','player_age'))" :disabled="disabledObj['player_age_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','player_age')">{{form['player_age']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','team') || $check_field('add','team') || $check_field('set','team')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="所在球队" prop="team">
												<el-input id="team" v-model="form['team']" placeholder="请输入所在球队"
							  v-if="user_group === '管理员' || (form['assist_analysis_id'] && $check_field('set','team')) || (!form['assist_analysis_id'] && $check_field('add','team'))" :disabled="disabledObj['team_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','team')">{{form['team']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','number_of_assists') || $check_field('add','number_of_assists') || $check_field('set','number_of_assists')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="助攻次数" prop="number_of_assists">
												<el-input id="number_of_assists" v-model="form['number_of_assists']" placeholder="请输入助攻次数"
							  v-if="user_group === '管理员' || (form['assist_analysis_id'] && $check_field('set','number_of_assists')) || (!form['assist_analysis_id'] && $check_field('add','number_of_assists'))" :disabled="disabledObj['number_of_assists_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','number_of_assists')">{{form['number_of_assists']}}</div>
											</el-form-item>
			</el-col>
					
	
	
	
	
	
	
		</el-row>
			<el-col :xs="24" :sm="12" :lg="8" class="el_form_btn_warp">
				<el-form-item v-if="$check_action('/assist_analysis/view','set') || $check_action('/assist_analysis/view','add') || $check_option('/assist_analysis/table','examine')">
					<el-button type="primary" @click="submit()">提交</el-button>
					<el-button @click="cancel()">取消</el-button>
				</el-form-item>
				<el-form-item v-else>
					<el-button @click="cancel()">返回</el-button>
				</el-form-item>
			</el-col>

		</el-form>
	</el-main>
</template>

<script>
	import mixin from "@/mixins/page.js";

	export default {
		mixins: [mixin],
		data() {
			return {
				field: "assist_analysis_id",
				url_add: "~/api/assist_analysis/add?",
				url_set: "~/api/assist_analysis/set?",
				url_get_obj: "~/api/assist_analysis/get_obj?",
				url_upload: "~/api/assist_analysis/upload?",

				query: {
					"assist_analysis_id": 0,
				},

				form: {
								"player_name":  '', // 球员姓名
										"player_position":  '', // 球员位置
										"player_age":  '', // 球员年龄
										"team":  '', // 所在球队
										"number_of_assists":  '', // 助攻次数
											"assist_analysis_id": 0, // ID
						
				},
				disabledObj:{
								"player_name_isDisabled": false,
										"player_position_isDisabled": false,
										"player_age_isDisabled": false,
										"team_isDisabled": false,
										"number_of_assists_isDisabled": false,
										},

	
		
		
		
		
	
			}
		},
		methods: {


	
	
			
	
			
	
			
	
			
	
		
			/**
			 * 获取对象之前
			 * @param {Object} param
			 */
			get_obj_before(param) {
				var form = "";
															// 获取缓存数据附加
				form = $.db.get("form");
							$.push(this.form ,form);
																									
				if(this.form && form){
					Object.keys(this.form).forEach(key => {
						Object.keys(form).forEach(dbKey => {
							// if(dbKey === "charging_standard"){
							// 	this.form['charging_rules'] = form[dbKey];
							// 	this.disabledObj['charging_rules_isDisabled'] = true;
							// };
							if(key === dbKey){
								this.disabledObj[key+'_isDisabled'] = true;
							}
						})
					})
				}
														$.db.del("form");

				return param;
			},

			/**
			 * 获取对象之后
			 * @param {Object} json
			 * @param {Object} func
			 */
			get_obj_after(json, func){
																				

			},

			/**
			 * 提交前验证事件
			 * @param {Object} 请求参数
			 * @return {String} 验证成功返回null, 失败返回错误提示
			 */
			submit_check(param) {
																																																			return null;
			},

			is_view(){
				var bl = this.user_group == "管理员";

				if(!bl){
					bl = this.$check_action('/assist_analysis/table','add');
					console.log(bl ? "你有表格添加权限视作有添加权限" : "你没有表格添加权限");
				}
				if(!bl){
					bl = this.$check_action('/assist_analysis/table','set');
					console.log(bl ? "你有表格添加权限视作有修改权限" : "你没有表格修改权限");
				}
				if(!bl){
					bl = this.$check_action('/assist_analysis/view','add');
					console.log(bl ? "你有视图添加权限视作有添加权限" : "你没有视图添加权限");
				}
				if(!bl){
					bl = this.$check_action('/assist_analysis/view','set');
					console.log(bl ? "你有视图修改权限视作有修改权限" : "你没有视图修改权限");
				}
				if(!bl){
					bl = this.$check_action('/assist_analysis/view','get');
					console.log(bl ? "你有视图查询权限视作有查询权限" : "你没有视图查询权限");
				}

				console.log(bl ? "具有当前页面的查看权，请注意这不代表你有字段的查看权" : "无权查看当前页，请注意即便有字段查询权限没有页面查询权限也不行");

				return bl;
			},
			/**
			 * 上传文件
			 * @param {Object} param
			 */
			uploadimg(param) {
				this.uploadFile(param.file, "avatar");
			},

		},
		created() {
												},
	}
</script>

<style>
	.avatar-uploader .el-upload {
		border: 1px dashed #d9d9d9;
		border-radius: 6px;
		cursor: pointer;
		position: relative;
		overflow: hidden;
	}

	.avatar-uploader .el-upload:hover {
		border-color: #409EFF;
	}

	.avatar-uploader-icon {
		font-size: 28px;
		color: #8c939d;
		width: 178px;
		height: 178px;
		line-height: 178px;
		text-align: center;
	}

	.avatar {
		width: 178px;
		height: 178px;
		display: block;
	}




</style>
